package cn.mazexal.tools;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

public class DaoUtil {

    public static SqlSession getSession() throws Exception{
        InputStream in = Resources.getResourceAsStream("SqlMapConfig.xml");
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        SqlSessionFactory factory = builder.build(in);
        System.out.println("getSession" + System.currentTimeMillis());
        SqlSession session = factory.openSession(true);
//        session.getConnection();
        System.out.println("finishGetSession" + System.currentTimeMillis());
        return session;
    }
}
